﻿var bgno=18;
bg=new Array(bgno+1);
randombgcommand='randombg();';
timeID=setInterval(randombgcommand,10000);
timeCheckWindowSize=setInterval('changescrollrule();',1000);
var winWidth,winHeight;


function randombg(){
	for (i=1;i<=bgno;i++){
		bg[i]='./images/'+i.toString()+'.jpg';
	}
	index=getrandomno();
	bgurl='url('+bg[index]+')';
	document.getElementById("bodycss").style.backgroundImage=bgurl;

}
function getrandomno(){
	t = Math.floor(Math.random() * bgno)+1;
	return t;
}
function chosepages(p){
	if (p=='./photos.html') clearTimeout(timeID);
		else timeID=setInterval(randombgcommand,10000);
	document.getElementById('iframeid').src=p;
	randombg();
	}
	
function setbg(url){
	document.getElementById('bodycss').style.backgroundImage='url('+url+')';
}

function mouseoverpic(p){
	parent.setbg('./images/'+p+'.jpg');
	document.getElementById(p).firstChild.style.opacity=1;
}

function mouseleavepic(p){
	document.getElementById(p).firstChild.style.opacity=0.3;
}

function fadein(p){
	document.getElementById(p).firstChild.style.opacity=1;
}



function findDimensions() {
	//get window-width
	if(window.innerWidth)
	winWidth=window.innerWidth;
	else if((document.body)&&(document.body.clientWidth))
	winWidth=document.body.clientWidth;
	
	//get window-height
	if(window.innerHeight)
	winHeight=window.innerHeight;
	else if((document.body)&&(document.body.clientHeight))
	winHeight=document.body.clientHeight;
	
	/*nasty hack to deal with doctype swith in IE*/
	if(document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
	{
	winHeight=document.documentElement.clientHeight;
	winWidth=document.documentElement.clientWidth;
	}
}

function changescrollrule(){
	findDimensions();
	if (winHeight<800||winWidth<1200) {
		document.getElementById('bodycss').style.backgroundAttachment='scroll';
		return};
	document.getElementById('bodycss').style.backgroundAttachment='fixed';
}